package com.burgeon.backend.Controller;

import com.burgeon.backend.service.CodeService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("checkcode")
public class CodeController extends BaseController{

    @Autowired
    private CodeService codeService;

    @RequestMapping("code")
    public ResponseResult<Void> Code(String phone, HttpSession session) {
        codeService.verificationCode(phone,session);
        return new ResponseResult<Void>(SUCCESS);
    }

    @RequestMapping("verify")
    public ResponseResult<Void> Verify(String phone,String code, HttpSession session) {
        session.setAttribute("phone",phone);
        codeService.Judge(phone,code,session);
        return new ResponseResult<Void>(SUCCESS);
    }

}
